<?php
/* @var $this UsersController */
/* @var $model Users */
/* @var $form TbActiveForm */
?>

<div class="form">

    <?php
    $form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(
        'id' => 'users-form',
//		'enableAjaxValidation' => true,
//		'clientOptions' => array(
//			'validateOnSubmit' => true,
//		),
        'htmlOptions' => array('enctype' => 'multipart/form-data'),
    ));
    ?>

    <?php echo $form->errorSummary($model); ?>

    <?php echo $form->textFieldControlGroup($model, 'userEmail', array('span' => 5, 'maxlength' => 255)); ?>

    <?php echo $form->textFieldControlGroup($model, 'userName', array('span' => 5, 'maxlength' => 255)); ?>

    <?php echo $form->textFieldControlGroup($model, 'userPhone', array('span' => 5, 'maxlength' => 255)); ?>

    <?php echo $form->textFieldControlGroup($model, 'userPassword', array('span' => 5, 'maxlength' => 32)); ?>

    <?php echo $form->dropDownListControlGroup($model, 'userGroup', array('admin' => 'Administrator', 'moder' => 'Moderator', 'user' => 'User')); ?>    

    <?php //echo $form->textFieldControlGroup($model, 'userRegDate', array('span' => 5, 'maxlength' => 20)); ?>

    <?php echo $form->dropDownListControlGroup($model, 'userActive', array('Выкл', 'Вкл')); ?> 

    <?php echo $form->fileFieldControlGroup($model, 'userImage', array('span' => 5, 'maxlength' => 255)); ?> 	
    <h4>Права доступа</h4>
    <div style="overflow:auto; height: 245px; width: auto; padding: 15px; margin:15px;border:1px dotted #999;">

        <ul class="nav-list">
            <?php foreach ($this->getAllActions() as $k => $v): ?>
                <li>
                    <div class="checkbox check-success">
                        <input type="checkbox" name="actions[]" value="<?php echo $v; ?>" id="<?php echo $v; ?>">
                        <label for="<?php echo $v; ?>"><?php echo $v; ?></label>
                    </div>								
                </li>
            <?php endforeach; ?>
        </ul>

<!--        <ul class="nav-list" style="padding:15px;">
            <?php //foreach ($this->module->userActions as $key => $value): ?>
                <li>
                    <div class="checkbox check-success">
                        <input type="checkbox" class="ch" id="<?php //echo $key; ?>">
                        <label for="<?php //echo $key; ?>"><?php //echo $key; ?></label>
                    </div>
                    <ul>
                        <?php //foreach ($value as $k => $v): ?>
                            <li>
                                <div class="checkbox check-success">
                                    <input type="checkbox" name="actions[]" value="<?php //echo $v; ?>" id="<?php //echo $v; ?>">
                                    <label for="<?php //echo $v; ?>"><?php //echo $k; ?></label>
                                </div>								
                            </li>
                        <?php //endforeach; ?>
                    </ul>				
                </li>
            <?php //endforeach; ?>
        </ul>-->
    </div>

    <script>
        $(document).ready(function() {
            $('.nav-list').find(':checkbox').prop('checked', true);
            $("input.ch").change(function() {
                var checked = $(this).is(':checked') ? true : false;
                $(this).parent().next('ul').find(':checkbox').prop('checked', checked);
            });
        });
    </script>
    <div class="form-actions">
        <?php
        echo TbHtml::submitButton($model->isNewRecord ? 'Cоздавать' : 'Cохранять', array(
            'color' => TbHtml::BUTTON_COLOR_PRIMARY,
            'size' => TbHtml::BUTTON_SIZE_LARGE,
        ));
        ?>
    </div>

    <?php $this->endWidget(); ?>

</div><!-- form -->